package BiShi.zhongxing;

import java.util.*;

public class Main3 {
    public static void main(String[] args) {
        int[][] arr  = new int[][]{{4,2,10},{4,6,20},{4,1,30},{1,3,50},{1,5,80}};
        //System.out.println(main(6,4,arr));
    }
    public static List<List<String>> main(int n, int root, String[] arr){
        Map<String, List<String>> map = new HashMap<>();
        List<List<String>> res = new ArrayList<>();
        int len = arr.length;
        for(int i = 0; i < len; i++){
            LinkedList<Character> tep = new LinkedList<>();
            for(int j = 0; i < arr[i].length(); j++){
                tep.add(arr[i].charAt(j));
            }
            tep.sort((o1, o2) -> o1-o2);
            String s = Arrays.toString(tep.toArray());
            if(map.containsKey(s)){
                map.get(s).add(arr[i]);
            }else{
                ArrayList<String> lis = new ArrayList<>();
                lis.add(arr[i]);
                map.put(s,lis);
                res.add(lis);
            }
        }
        return res;
    }


}